import QuestionTitleConf, {QuestionTitlePropsType} from "./QuestionTitle";
import QuestionInputConf, {QuestionInputPropsType} from "./QuestionInput";
import {FC} from "react";
import QuestionParagraphConf, {QuestionParagraphPropsType} from "./QuestionParagraph";
import QuestionInfoConf, {QuestionInfoPropsType} from "./QuestionInfo";
import QuestionTextareaConf, {QuestionTextareaPropsType} from "./QuestionTextarea";
import QuestionRadioConf, {QuestionRadioPropsType, QuestionRadioStatPropsType} from "./QuestionRadio";
import QuestionCheckboxConf, {QuestionCheckboxPropsType, QuestionCheckboxStatType} from "./QuestionCheckbox";

export type ComponentPropsType =
    QuestionTitlePropsType
    & QuestionInputPropsType
    & QuestionParagraphPropsType
    & QuestionInfoPropsType
    & QuestionTextareaPropsType
    & QuestionRadioPropsType
    & QuestionCheckboxPropsType

type ComponentStatPropsType = QuestionRadioStatPropsType & QuestionCheckboxStatType

export type ComponentConfType = {
    title: string;
    type: string;
    Component: FC<ComponentPropsType>;
    PropComponent: FC<ComponentPropsType>;
    defaultProps: ComponentPropsType;
    StatComponent?: FC<ComponentStatPropsType>
}


const componentConfList: ComponentConfType[] = [QuestionInputConf, QuestionTitleConf, QuestionParagraphConf, QuestionInfoConf, QuestionTextareaConf, QuestionRadioConf, QuestionCheckboxConf];

export const componentConfGroup = [
    {groupName: '文本显示', components: [QuestionInfoConf, QuestionTitleConf, QuestionParagraphConf]},
    {groupName: '用户输入', components: [QuestionInputConf, QuestionTextareaConf]},
    {groupName: '用户显示', components: [QuestionRadioConf, QuestionCheckboxConf]}
]

export function getComponentConfByType(type: string) {
    return componentConfList.find(c => c.type === type)
}
